
/*
 * Copyright (c) 2022-2023 Termony Co., Ltd. All rights reserved.
 *
 * This program is OPEN SOURCE software: you can redistribute it and/or modify it
 * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
 * either version 1.0 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the Phytium Public License for more details.
 *
 *
 * FilePath: sdmmc_system.c
 * Date: 2022-02-10 14:53:44
 * LastEditTime: 2022-02-25 11:47:44
 * Description:  This files is for sdmmc baremetal port
 *
 * Modify History:
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 * 1.0   zhugengyu  2022/11/15  init commit
 */

#include "sdmmc_system.h"
#include "los_compiler.h"
#include "los_memory.h"
#include "los_task.h"

void sdmmc_sys_delay_ms(uint32_t msecs)
{
    LOS_TaskDelay(msecs * LOSCFG_BASE_CORE_TICK_PERIOD_MS);
}

void *sdmmc_sys_heap_caps_malloc(size_t size, uint32_t caps)
{
    if (caps & MALLOC_8_ALIGN) {
        return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, 8);
    } else if (caps & MALLOC_32_ALIGN) {
        return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, 32);
    } else if (caps & MALLOC_64_ALIGN) {
        return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, 64);
    } else if (caps & MALLOC_256_ALIGN) {
        return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, 256);
    } else if (caps & MALLOC_512_ALIGN) {
        return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, 512);
    } else {
        return LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
    }
}

void sdmmc_sys_free(void *p)
{
    (VOID) LOS_MemFree(OS_SYS_MEM_ADDR, p);
}